package com.woniuxy.dao;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.woniuxy.controller.form.CondFrom;
import com.woniuxy.controller.info.ProjectIdAndNameInfo;
import com.woniuxy.controller.info.ProjectIdAndNameInfo;
import com.woniuxy.controller.info.UserAndAccountInfo;
import com.woniuxy.model.Project;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.woniuxy.utils.GetSqlUtil;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 马世亮
 * @since 2022-02-15
 */
public interface ProjectDao extends BaseMapper<Project> {

    @Select("SELECT * FROM t_project WHERE project_createname_id =#{uid} AND (project_name = #{condFrom} OR project_id = #{condFrom}) ORDER BY project_id DESC")
    List<Project> getProjects(@Param("condFrom") String condFrom, @Param("uid") Integer uid);

    @Select("SELECT project_name FROM t_project ")
    List<Project> getAllprojectName();
    @Select("SELECT project_id FROM t_project WHERE project_createname_id=#{uid} AND project_state=1")
    List<Integer> selectMyProject(Integer uid);

    @Select("SELECT project_id,project_name FROM t_project WHERE project_createname_id=#{uid} AND project_state=1")
    List<ProjectIdAndNameInfo> selectMyProjectByUidAndState(Integer uid);

    @SelectProvider(type = GetSqlUtil.class,method = "getHaveMyProjectSql")
    List<ProjectIdAndNameInfo> selectHaveMyProjectByProjectList(@Param("projectIds") List<Integer> projectIds);
}
